addcomputed inherits extra initremote parameters
authorJoey Hess <joeyh@joeyh.name>
Wed, 26 Feb 2025 13:45:35 +0000 (09:45 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 26 Feb 2025 13:45:35 +0000 (09:45 -0400)
This is limited because the remote config is a field/value map. So order
is not preserved, and when 2 parameters have the same field name, only
the last one will be passed.

Command/AddComputed.hs
Remote/Compute.hs
doc/git-annex-addcomputed.mdwn
doc/special_remotes/compute.mdwn

index 8af8e7c90026d2af95d07028f8e5d0b0d7c98f1b..8b983a738ccc51b52f5d388259325130687b4e89 100644 (file)
@@ -88,8 +88,8 @@ perform o r program = do
        repopath <- fromRepo Git.repoPath
        subdir <- liftIO $ relPathDirToFile repopath (literalOsPath ".")
        let state = Remote.Compute.ComputeState
-               -- TODO add inherited initremote parameters
-               { Remote.Compute.computeParams = computeParams o
+               { Remote.Compute.computeParams = computeParams o ++
+                       Remote.Compute.defaultComputeParams r
                , Remote.Compute.computeInputs = mempty
                , Remote.Compute.computeOutputs = mempty
                , Remote.Compute.computeSubdir = subdir
index b6ba1dbf2e7eadb2df1cd6d974bee479e5e33aab..09ab45687a0218ad901429c1c04a697aa1f8a857 100644 (file)
@@ -17,6 +17,7 @@ module Remote.Compute (
        getComputeProgram,
        runComputeProgram,
        ImmutableState(..),
+       defaultComputeParams,
 ) where
 
 import Annex.Common
@@ -127,6 +128,11 @@ computeConfigParser _ = return $ RemoteConfigParser
                )
        }
 
+defaultComputeParams :: Remote -> [String]
+defaultComputeParams = map mk . M.toList . getRemoteConfigPassedThrough . config
+  where
+       mk (f, v) = fromProposedAccepted f ++ '=' : v
+
 newtype ComputeProgram = ComputeProgram String
        deriving (Show)
 
index 1da287f0cf18d7c9168fa091f61cf611e0b7403e..245d4a04b0f86f9abf748ca27f54c173cc21faf4 100644 (file)
@@ -33,7 +33,9 @@ Some examples of how this might look:
     git-annex addcomputed --to=y -- compress foo --level=9
     git-annex addcomputed --to=z -- clip foo 2:01-3:00 combine with bar to baz
 
-
+Note that parameters that were passed to `git-annex initremote` 
+when setting up the compute special remote will be appended to the end of
+the parameters provided to `git-annex addcomputed`.
 
 # OPTIONS
 
@@ -88,6 +90,8 @@ Some examples of how this might look:
 
 [[git-annex-recompute]](1)
 
+[[git-annex-initremote]](1)
+
 # AUTHOR
 
 Joey Hess <id@joeyh.name>
index b840f5fcbee285bc69f952cf77bcb0163f0e45d3..c3f4186008a8e06ae44b5ae1788da636a20e8e33 100644 (file)
@@ -2,6 +2,10 @@ While other remotes store the contents of annexed files somewhere,
 this special remote uses a program to compute the contents of annexed
 files.
 
+To add a file to a compute special remote, use the [[git-annex-addcomputed]]
+command. Once a file has been added to a compute special remote, commands
+like `git-annex get` will use it to compute the content of the file.
+
 To enable an instance of this special remote:
 
     # git-annex initremote myremote type=compute program=git-annex-compute-foo
@@ -11,16 +15,11 @@ program to use to compute the contents of annexed files. It must start with
 "git-annex-compute-". The program needs to be installed somewhere in the
 `PATH`.
 
-To add a file to a compute special remote, use the [[git-annex-addcomputed]]
-command. Once a file has been added to a compute special remote, commands
-like `git-annex get` will use it to compute the content of the file.
-
-You can provide other parameters to `initremote`, in order to provide
-default configuration values to use when adding files with
-[[git-annex-addcomputed]]. To see a list of all the configuration values
-supported by a given program, pass `--whatelse` to `initremote`:
+All other "field=value" parameters passed to `initremote` will be passed
+to the program when running [[git-annex-addcomputed]]. Note that when the
+program takes a dashed option, it can be provided after "--":
 
-    # git-annex initremote myremote type=compute program=git-annex-compute-foo --whatelse
+    # git-annex initremote myremote type=compute program=git-annex-compute-foo -- --level=9
 
 ## compute programs